
#include "mqPool.h"
#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
	if(argc < 2)
	{
		cout<<argv[0]<<" conf"<<endl;
		return 0;
	}
	MqPool *p = MqPool::Instance(argv[1]);
	if(p!= NULL)
	{
		MYSQL  *conn = NULL;
		int fId = 0; 
		conn = p->GetWriter(fId, 0);
		if(conn == NULL)
		{
			p->CloseWriter(fId, conn);
			ERRO << ": can't get connection!"<<endl;
			return NULL;
		}
                long t1 = time(NULL);
                for(int i=0; i<100000;i++)
		{
			const char *sql="select uuid from guid where id=1";
			if(mysql_real_query(conn, sql, strlen(sql) ) == 0){
				MYSQL_RES *result = mysql_store_result(conn);
				if(result != NULL){
					long rownum = mysql_num_rows(result);
					if (rownum > 0 )
					{
						MYSQL_ROW row;
						if((row = mysql_fetch_row(result)))
						{	
						//	cout<<"result :"<<(char *)row[0]<< endl; 
						}
					}
					mysql_free_result(result);
				}
			}
			else
			{     ERRO <<" :"<< mysql_error(conn) << endl; }
		}
                long t2 = time(NULL);
                cout<<"req/s = "<< 100000.00/(t2-t1) << endl;
		p->CloseWriter(fId, conn);
	}
	if(p!= NULL)
		MqPool::Release();
	return 0;
}

